package licode.unisop.realm.adapter.web;

import licode.unisop.client.utils.PlatformCheck;
import licode.unisop.realm.client.api.SiRealmService;
import licode.unisop.realm.client.dto.SiRealmDTO;
import licode.unisop.unilite.result.UniReturnResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 适配RESTFUL接口访问，处理领域的操作
 *
 * @author WR
 */
@RestController
@UniReturnResult
@RequestMapping("/user-api/v1/internal/realm")
public class RealmController {
    @Resource
    private HttpServletRequest request;

    @Resource
    private PlatformCheck platformCheck;

    @Resource
    private SiRealmService siRealmService;

    @PostMapping("/save")
    public boolean saveRealm(@RequestBody SiRealmDTO realm) {
        platformCheck.checkModalToken(request);
        siRealmService.saveRealm(realm);
        return true;
    }
}
